<?php
	class trangthaidb
	{
		public function Add($TenTrangThai, $MoTa )
		{
			$sql="INSERT INTO `tbl_trangthai`(`TenTrangThai`, `MoTa`) VALUES ('$TenTrangThai', '$MoTa')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaTrangThai)
		{
			$sql = "DELETE FROM `tbl_trangthai` WHERE MaTrangThai = $MaTrangThai";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaTrangThai, $TenTrangThai, $MoTa)
		{
			$sql = "UPDATE `tbl_trangthai` 
					SET `TenTrangThai`='$TenTrangThai', 
						`MoTa`='$MoTa'
					WHERE `MaTrangThai` = $MaTrangThai";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function GetList($MaTrangThai, $TenTrangThai, $MoTa)
		{
			$sql = "SELECT * FROM `tbl_trangthai` WHERE 1";
			if($MaTrangThai != 0)
				$sql .= " AND MaTrangThai = $MaTrangThai";
			
			if($TenTrangThai != "")
				$sql .= " AND TenTrangThai LIKE '%$TenTrangThai%'";
			
			if($MoTa != "")
				$sql .= " AND MoTa LIKE '%$MoTa%'";
				
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>